package com.cn.configuration;

import com.cn.service.DataSourceService;

import java.util.ArrayList;
import java.util.List;

/**
 * @author chenming
 * @version 1.0
 * @date 2022/9/23 16:27
 */
public class InitialCache {

    private List<DataSourceService> services;

    public InitialCache(){
        services = new ArrayList<DataSourceService>();
    }

    public DataSourceService getServices(String serviceName) {
        for (DataSourceService dataSourceService : services) {
            if(dataSourceService.getName().equals(serviceName)){
                System.out.println("Returning cached " + serviceName + " object");
            }
        }
        return null;
    }

    public void addService(DataSourceService newService)
    {
        if (!services.contains(newService))
        {
            services.add(newService);
        }
    }

}
